package mygang.dao;

import java.util.List;
import mygang.model.SystemSetting;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author Volodymyr Lavrynovych <volodya.lavrynovych@gmail.com>
 * date: 14/08/2012
 */
@Repository("systemDAO")
@Transactional
public class SystemDAOImpl extends AbstractDAO implements SystemDAO {

    public SystemSetting getSystemSettingById(long id) {
        return getHibernateTemplate().load(SystemSetting.class, id);
    }

    public SystemSetting getSystemSettingByName(String name) {
        return (SystemSetting) getHibernateTemplate().findByNamedParam("from SystemSetting where name like :name", "name", name).get(0);
    }

    public List<SystemSetting> getAll() {
        List<SystemSetting> list = (List<SystemSetting>) getHibernateTemplate().find("from SystemSetting");
        return list;
    }
}